<template>
  <ul :class="[$store.state.appPrefix + '-c-layout-left-menu']">
    <li
      v-for="item in showList"
      :key="item.name"
      :class="{'actived': item.menuUrl === $route.path}"
      @click="clickMenu(item)"
    >
      {{ item.name }}
    </li>
  </ul>
</template>
<script>

export default {
  name: 'leftMenu',
  data() {
    return {
      curPath: '/with-left-page/exam-object-list',
      list: [
        {
          name: '主观题',
          menuUrl: '/with-left-page/exam-list'
        },
        {
          name: '客观题',
          menuUrl: '/with-left-page/exam-list-object'
        },
      ],
    }
  },
  computed: {
    showList() {
      const allRoutes = this.$router.options.routes
      const parentPath = this.$route.matched[0].path

      return allRoutes.reduce((siblings, route) => {
        if (route.path === parentPath) {
          siblings.push(...(route.children.map(item => ({
            name: item.meta?.title || '未命名',
            menuUrl: item.path
          })) || []));
        }
        return siblings;
      }, [])
    }
  },
  methods: {
    clickMenu(item) {
      this.curPath = item.menuUrl
      this.$router.push({ path: this.curPath })
    }
  },
  created() {
    this.curPath = this.$route.path
    console.log(this.$route, this.$router)
    if (this.isShowSkillEval) {
      this.list = [
        {
          name: '客观题',
          menuUrl: '/with-left-page/exam-list-object'
        },
        {
          name: '主观题',
          menuUrl: '/with-left-page/exam-list'
        },
        {
          name: '鉴赏题',
          menuUrl: '/with-left-page/appreciate-list'
        },
        // {
        //   name: '技能',
        //   menuUrl: '/with-left-page/skill-exam-list'
        // },
        // {
        //   name: '学期自我评价',
        //   menuUrl: '/with-left-page/self-evaluation'
        // },
        // {
        //   name: '课堂过程评价',
        //   menuUrl: '/with-left-page/classroom-evaluation'
        // },
        {
          name: '课外活动',
          menuUrl: '/with-left-page/outside-class-activity'
        },
        {
          name: '校外学习',
          menuUrl: '/with-left-page/after-school-activity'
        },
        // {
        //   name: '作业中心',
        //   menuUrl: '/with-left-page/home-work-centre'
        // },
        // {
        //   name: '选修课记录',
        //   menuUrl: '/with-left-page/optional-course'
        // },
        // {
        //   name: '获奖记录',
        //   menuUrl: '/with-left-page/award-record'
        // },
        {
          name: '荣誉奖项',
          menuUrl: '/with-left-page/honor-awards'
        },
        {
          name: '综合评价',
          menuUrl: '/with-left-page/evaluate-task'
        },
        // {
        //   name: '课堂评价记录',
        //   menuUrl: '/with-left-page/assessment-evaluate'
        // },
        {
          name: '评价报告',
          menuUrl: '/with-left-page/report'
        },
        //   name: '帮助反馈',
        //   menuUrl: '/with-left-page/help-feedback'
        // },
        {
          name: '课堂考勤',
          menuUrl: '/with-left-page/attendance'
        }
      ]

    }
  },
  mounted() {
  }
};
</script>
